package cn.xshi.sys.service.impl;

import cn.xshi.common.base.BaseService;
import cn.xshi.common.util.ExceptionUtil;
import cn.xshi.sys.dao.SysAreaRegionDao;
import cn.xshi.sys.form.SysAreaRegionForm;
import cn.xshi.sys.init.GlobalPersistentComponent;
import cn.xshi.sys.model.SysAreaRegion;
import cn.xshi.sys.service.SysAreaRegionService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
 * @Desc 行政区划
 * @Author 邓纯杰
 * @CreateTime 2012-12-12 12:12:12
 */
@Service
public class SysAreaRegionServiceImpl extends BaseService implements SysAreaRegionService {

	@Resource
    SysAreaRegionDao sysAreaRegionDao;

	@Resource
    GlobalPersistentComponent globalPersistentComponent;

	/**
	* 分页
	* @param sysAreaRegionForm
	* @return
	*/
	public List<SysAreaRegion> getSysAreaRegionListByCondition(SysAreaRegionForm sysAreaRegionForm){
		try{
			return sysAreaRegionDao.getSysAreaRegionListByCondition(sysAreaRegionForm);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	* 查询对象
	* @param id
	* @return
	*/
	public SysAreaRegion getSysAreaRegionById(String id){
		try{
			SysAreaRegion sysAreaRegion = sysAreaRegionDao.getSysAreaRegionById(id);
			return sysAreaRegion;
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	* 添加
	* @param sysAreaRegion
	* @return
	*/
	public int addSysAreaRegion(SysAreaRegion sysAreaRegion){
		int i = 0;
		try {
			i = sysAreaRegionDao.addSysAreaRegion(sysAreaRegion);
			globalPersistentComponent.initSysAreaRegion();
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 修改
	* @param sysAreaRegion
	* @return
	*/
	public int updateSysAreaRegion(SysAreaRegion sysAreaRegion){
		int i = 0;
		try {
			i = sysAreaRegionDao.updateSysAreaRegion(sysAreaRegion);
			globalPersistentComponent.initSysAreaRegion();
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 修改（根据动态条件）
	* @param sysAreaRegion
	* @return
	*/
	public int updateSysAreaRegionBySelective(SysAreaRegion sysAreaRegion){
		int i = 0;
		try {
			i = sysAreaRegionDao.updateSysAreaRegionBySelective(sysAreaRegion);
			globalPersistentComponent.initSysAreaRegion();
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 删除
	* @param condition 
	* @return
	*/
	public int delSysAreaRegion(Map<String,Object> condition){
		int i = 0;
		try {
			i = sysAreaRegionDao.delSysAreaRegion(condition);
			globalPersistentComponent.initSysAreaRegion();
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 批量添加
	* @param sysAreaRegionList
	* @return
	*/
	public int addBatchSysAreaRegion(List<SysAreaRegion> sysAreaRegionList){
		int i = 0;
		try {
			i = sysAreaRegionDao.addBatchSysAreaRegion(sysAreaRegionList);
			globalPersistentComponent.initSysAreaRegion();
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 批量修改
	* @param sysAreaRegionList
	* @return
	*/
	public int updateBatchSysAreaRegion(List<SysAreaRegion> sysAreaRegionList){
		int i = 0;
		try {
			i = sysAreaRegionDao.updateBatchSysAreaRegion(sysAreaRegionList);
			globalPersistentComponent.initSysAreaRegion();
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 批量修改（根据动态条件）
	* @param sysAreaRegionList
	* @return
	*/
	public int updateBatchSysAreaRegionBySelective(List<SysAreaRegion> sysAreaRegionList){
		int i = 0;
		try {
			i = sysAreaRegionDao.updateBatchSysAreaRegionBySelective(sysAreaRegionList);
			globalPersistentComponent.initSysAreaRegion();
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}
}
